package cn.yuyin.item;

import java.io.ByteArrayOutputStream;
import java.io.IOException;
import java.io.InputStream;

import javax.microedition.lcdui.Graphics;
import javax.microedition.lcdui.Image;

public class ImageItem extends Item{

	public Image image;
	public ImageItem(int x, int y, String text,InputStream is) throws IOException {
		super(x, y, text);
		ByteArrayOutputStream bout = new ByteArrayOutputStream();
		int ch = 0;
		while ((ch = is.read()) != -1) {
			bout.write(ch);
		}

		byte[] imgeByte = bout.toByteArray();
		image = Image.createImage(imgeByte, 0, imgeByte.length);
	}

	public void paint(Graphics g) {
		int color = g.getColor();		
		g.drawImage(image, x, y, 0);
		g.setColor(color);
		
	}

	public void keyPressed(int keyCode) {
		// TODO Auto-generated method stub
		
	}

	public void keyReleased(int keyCode) {
		// TODO Auto-generated method stub
		
	}

	public void pointerPressed(int x, int y) {
		// TODO Auto-generated method stub
		
	}

	public void pointerReleased(int x, int y) {
		// TODO Auto-generated method stub
		
	}

}
